package cn.com.xuhx.testService;

import cn.com.xuhx.pojo.User;
import cn.com.xuhx.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest
public class InsertTest {

    @Autowired
    private UserService userService;

    /**
     * 批量添加
     */
    @Test
    public void batchInsert(){
        //INSERT INTO T_USERS ( id, name, age, address, tel, sfzh, bornday ) VALUES ( ?, ?, ?, ?, ?, ?, ? )
        List<User> users = new ArrayList<>();
        User user1 = new User("李逍遥", 16, "余杭镇", "15221182743", "321112204885261177", new Date());
        users.add(user1);

        User user2 = new User("赵灵儿", 16, "仙灵岛", "15221181743", "321112204885261178", new Date());
        users.add(user2);

        User user3 = new User("林月如", 17, "林家堡", "15221183743", "321112204885261174", new Date());
        users.add(user3);

        userService.saveBatch(users);
    }
}
